//package com.zetcode;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;


public class Menu extends JFrame {
	
	public Menu() {
		
		setTitle ("JMenuBar");
		
		JMenuBar menubar = new JMenuBar();
		ImageIcon search = new ImageIcon ("search.png");
		ImageIcon exit = new ImageIcon ("exit-32.png");
		
		JMenu file = new JMenu("File");
		file.setMnemonic(KeyEvent.VK_F);
		
		JMenuItem fileSearch = new JMenuItem ("Search", search);
		fileSearch.setMnemonic (KeyEvent.VK_S);
		fileSearch.addActionListener (new ActionListener() {
			public void actionPerformed (ActionEvent event) {
				new Search().setVisible(true);
			}
		});
		
		JMenuItem fileExit = new JMenuItem ("Close", exit);
		fileExit.setMnemonic (KeyEvent.VK_C);
		fileExit.addActionListener (new ActionListener() {
			public void actionPerformed (ActionEvent event) {
				System.exit (0);
			}
		});
		
		file.add (fileSearch);
		file.add (fileExit);
		
		menubar.add (file);
		
		setJMenuBar (menubar);
		
		setSize (250, 200);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public static void main (String[] args) {
		
		new Menu();
		//new Search().setVisible(true);
	}
	
}	


